﻿$.ajaxSetup({ url: "Proxy.ashx", type: "post", dataType: "json" });

function btnAdd_Click() {
    var cityId = $("#ddl_City").val();
    var areaId = $("#ddl_Area").val();
    var streetId = $("#ddl_Street").val();
    var name = $("#txtName").val();     // 车位名称

    var sensorCode = $("#txtSensorCode").val();     // 泊位传感器编号
    var connection = $("#txtConnection").val();     // 连接方式
    var berthModel = $("#ddl_BerthModel").val();     // 泊位车型
    var berthType = $("#ddl_BerthType").val();     // 泊位类型
    var restriction = $("#ddl_Restriction").val();     // 停车限制条件
    var feeRule = $("#ddl_FeeRule").val();     // 收费规则
    var continuousLong = $("#ddl_ContinuousLong").val();     // 连续时长校费规则
    var longitude = $("#txtLongitude").val();     // 经度
    var latitude = $("#txtLatitude").val();     // 纬度

    $.ajax({
        data: { method: "AddParkingSpace", cityId: cityId, areaId: areaId, streetId: streetId, name: name, sensorCode: sensorCode, connection: connection, berthModel: berthModel, berthType: berthType, restriction: restriction, feeRule: feeRule, continuousLong: continuousLong, longitude: longitude, latitude: latitude }
        , success: function (json) {

            var msg = "";
            if (json.isSuccess == "true") {
                msg = "数据添加成功！"
            }
            else {
                msg = "数据添加失败，请重试..."
            }
            alert(msg);
        }
    });
}

function InitBerthModel() {
    $.ajax({
        data: { method: "ListBerthModels" }
        , success: function (json) {
            $("#ddl_BerthModel").append("#full_BerthModel", json.BerthModels);
        }
    });
}
function InitBerthType() {
    $.ajax({
        data: { method: "ListBerthType" }
        , success: function (json) {
            $("#ddl_BerthType").append("#full_BerthType", json.BerthType);
        }
    });
}
function InitRestrictions() {
    $.ajax({
        data: { method: "ListRestrictions" }
        , success: function (json) {
            $("#ddl_Restriction").append("#full_Restriction", json.Restrictions);
        }
    });
}
function InitFeeRules() {
    $.ajax({
        data: { method: "ListFeeRules" }
        , success: function (json) {
            $("#ddl_FeeRule").append("#full_FeeRule", json.FeeRules);
        }
    });
}
function InitContinuousLong() {
    $.ajax({
        data: { method: "ListContinuousLong" }
        , success: function (json) {
            $("#ddl_ContinuousLong").append("#full_ContinuousLong", json.ContinuousLong);
        }
    });
}



//  , restriction, feeRule,

function init() {
    BindCity();
    InitBerthModel();
    InitBerthType();
    InitRestrictions();
    InitFeeRules();
    InitContinuousLong();

    $("#btnAdd").click(function () {
        btnAdd_Click();
    });
}

